﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Modules.MENU.Components;

namespace ASPNETVN.PORTAL.Modules.MENU.Controls
{
    public partial class OneLevel1 : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LiteralControl literal = new LiteralControl("");
            literal.Text += "<div class='MenuLink'>";

            IList<Item> allItems = Item.SelectCollectionAll(this.ModuleID);
            IList<Item> topItems = allItems.Where(x => x.ParentID == 0).OrderBy(x => x.SortOrder).ToList();

            foreach (Item topItem in topItems)
            {
                literal.Text += string.Format("<a class='MenuLinkItem' href='{1}'>» {0}</a>", topItem.Title, topItem.Url);
            }
            literal.Text += "</div>";
            Container.Controls.Add(literal);
        }
    }
}